package com.approval.approvalapp.index.dbsx.zxhf;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.approval.approvalapp.R;
import com.approval.approvalapp.bean.TshfDbXqBean;
import com.approval.approvalapp.bean.ZxhfxqdbBean;
import com.approval.approvalapp.index.dbsx.tshf.adapter.TxhfxqAdapter;
import com.approval.approvalapp.util.ErrorBeanUtil;
import com.approval.approvalapp.util.SpUtil;
import com.approval.approvalapp.util.base.BaseActivity;
import com.approval.approvalapp.util.net.NetRequsetUtil;
import com.approval.approvalapp.util.net.interfacepac.NetDownResponse;
import com.bumptech.glide.Glide;
import com.lxj.xpopup.XPopup;

import java.text.SimpleDateFormat;
import java.util.Date;

import butterknife.Bind;
import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;

public class ZxhfxqYbActivity extends BaseActivity {
    @Bind(R.id.back_iv)
    ImageView backIv;
    @Bind(R.id.titleTv1)
    TextView titleTv1;
    @Bind(R.id.zxr_tv)
    TextView zxrTv;
    @Bind(R.id.zxdw_tv)
    TextView zxdwTv;
    @Bind(R.id.zxsj_tv)
    TextView zxsjTv;
    @Bind(R.id.zxdh_tv)
    TextView zxdhTv;
    @Bind(R.id.contant_tv)
    TextView contantTv;
    @Bind(R.id.button)
    Button button;
    @Bind(R.id.title_tttv)
    TextView title_tttv;
    @Bind(R.id.rv)
    RecyclerView rv;
    private String title;
    private String zxr;
    private String zxdw;
    private String zxsj;
    private String applyid;

    @Override
    public int getLayoutId() {
        return R.layout.activity_zxhfxq_yb;
    }

    @Override
    public void initView() {
        title = getIntent().getStringExtra("title");
        zxr = getIntent().getStringExtra("zxr");
        zxdw = getIntent().getStringExtra("zxdw");
        zxsj = getIntent().getStringExtra("zxsj");
        applyid = getIntent().getStringExtra("applyid");

        title_tttv.setText(title);
        zxrTv.setText(zxr);
        zxdwTv.setText(zxdw);
        zxsjTv.setText(zxsj);
    }

    @Override
    public void initData() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("username", SpUtil.getString(this, SpUtil.USER_NAME, ""));
        jsonObject.put("applyid", applyid);
        NetRequsetUtil.getInstance().netRequestPostJson("v1/user/get_zx_show", jsonObject.toString(), new NetDownResponse() {
            @Override
            public void success(String str) {
                TshfDbXqBean zxhfxqdbBean = JSON.parseObject(str, TshfDbXqBean.class);
                zxdhTv.setText(zxhfxqdbBean.getMphone());
                contantTv.setText(zxhfxqdbBean.getContent());

                rv.setLayoutManager(new LinearLayoutManager(ZxhfxqYbActivity.this));
                TxhfxqAdapter txhfxqAdapter  = new TxhfxqAdapter();
                txhfxqAdapter.setHandleoptionsBeanList(zxhfxqdbBean.getHandleoptions());
                rv.setAdapter(txhfxqAdapter);
            }

            @Override
            public void errowithresponse(String str) {
                ErrorBeanUtil.getErrorMessage(str);
            }

            @Override
            public void erro() {
                ErrorBeanUtil.getErrorMessage(null);
            }

            @Override
            public void finish() {

            }
        });
    }

    @OnClick({R.id.back_iv})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back_iv:
                finish();
                break;
        }
    }
}
